﻿using System.IO;
using System.ServiceProcess;

namespace WinAPI
{
    public class DriverLoader
    {
        //short and long names in perspective
        static string[] serviceNames = { "Virtual HDD", "Virtual HDD" };
        //ServiceControlManager analogue
        static ServiceController sc = new ServiceController(serviceNames[0]);

        public static void LoadDriver()
        {
            ServiceInstaller.Install(serviceNames[0], serviceNames[1], Directory.GetCurrentDirectory() + @"\VirtualDiskDriver.sys");
            sc.Start();
        }

        public static void UnloadDriver()
        {
            sc.Stop();
            ServiceInstaller.Uninstall(serviceNames[0]);
        }
    }
}


